package sale.wxb.loveshopping.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import sale.wxb.loveshopping.entity.common.Result;
import sale.wxb.loveshopping.entity.model.RelationResource;
import sale.wxb.loveshopping.service.IRelationResourceService;

import java.util.List;

@RestController
@RequestMapping("resource")
@Api(tags = "文件资源")
public class ResourceController {
    @Autowired
    private IRelationResourceService resourceRelationService;

    @ApiOperation("单文件上传")
    @PostMapping("single-file-upload")
    public Result<RelationResource> singleFileUpload(@RequestParam("files") MultipartFile file) {
        return Result.success(resourceRelationService.singleFileUpload(file));
    }

    @ApiOperation("多文件上传")
    @PostMapping("multiple-file-upload")
    public Result<List<RelationResource>> multipleFileUpload(@RequestParam("files") List<MultipartFile> files) {
        return Result.success(resourceRelationService.multipleFileUpload(files));
    }
}
